package com.woniuxy.common.mapper;

import com.woniuxy.common.constant.UserConstant;
import org.apache.ibatis.annotations.Param;
import com.woniuxy.common.entity.CenterUser;
import com.woniuxy.common.entity.CenterUserExample;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.*;

public interface CenterUserMapper {
    long countByExample(CenterUserExample example);

    int deleteByExample(CenterUserExample example);

    int deleteByPrimaryKey(String id);

    int insert(CenterUser record);

    int insertSelective(CenterUser record);

    List<CenterUser> selectByExample(CenterUserExample example);

    CenterUser selectByPrimaryKey(String id);

    int updateByExampleSelective(@Param("record") CenterUser record, @Param("example") CenterUserExample example);

    int updateByExample(@Param("record") CenterUser record, @Param("example") CenterUserExample example);

    int updateByPrimaryKeySelective(CenterUser record);

    int updateByPrimaryKey(CenterUser record);

    /**
     * @return java.util.Map<java.lang.String, java.lang.Object>
     * @Author ArmWatt
     * @Date 2020/5/13
     * @Param []
     * @Description 查询所有待审批的用户认证
     **/
    @Select("SELECT `name`,nickname,intro,phone,photo,center_credentialcode,center_verifydata,center_usertype,id FROM center_user WHERE center_accountstatus = '0'")
    List<Map<String, Object>> selectAllUserApply();

    /**
     * @return int
     * @Author ArmWatt
     * @Date 2020/5/13
     * @Param [id]
     * @Description 通过用户认证
     **/
    @Update("UPDATE center_user SET center_accountstatus = '1' WHERE id = #{id}")
    int passUserApply(@Param("id") String id);

    /**
     * @return int
     * @Author ArmWatt
     * @Date 2020/5/13
     * @Param [id]
     * @Description 用户认证拒绝
     **/
    @Update("UPDATE center_user SET center_accountstatus = '2', `name`= 'rejectuser',phone='rejectphone' WHERE id = #{id}")
    int rejectUserApply(@Param("id") String id);

    /**
     * @return int
     * @Author ArmWatt
     * @Date 2020/5/16
     * @Param [id]
     * @Description 封号
     **/
    @Update("UPDATE center_user SET center_accountstatus = '2' WHERE id = #{id}")
    int suspendUser(@Param("id") String id);

    /**
     * @return int
     * @Author ArmWatt
     * @Date 2020/5/16
     * @Param [id]
     * @Description 解封账号
     **/
    @Update("UPDATE center_user SET center_accountstatus = '1' WHERE id = #{id}")
    int unsuspendUser(@Param("id") String id);

    /**
     * @return int
     * @Author ArmWatt
     * @Date 2020/5/16
     * @Param [id]
     * @Description 重置密码
     **/
    @Update("UPDATE center_user SET password = 'b58cc6dd56adfdb2118a98c3472a8567' , salt = 'ad090' WHERE id = #{id}")
    int resetPassWord(@Param("id") String id);

}